<script src="../lib/jquery-1.8.2.min.js"></script>
<script src="../lib/template/laytpl.js"></script>
<script src="../lib/laycode/laycode.js"></script>
<div class="laycode" style="width: 100%;float: left;height: auto;margin:0px;padding:0px;">
    <pre class="code">
&lt;textarea style="display: none;" id="template"&gt;
    &lt;select name="" id=""&gt;
        &lt;%# for(var i=0;i&lt;d.area.length;i++){ %&gt;
        &lt;option value="&lt;%=d.area[i].code%&gt;"&gt;&lt;%=d.area[i].name%&gt;&lt;/option&gt;
        &lt;%# } %&gt;
    &lt;/select&gt;
&lt;/textarea&gt;
&lt;div id="target"&gt;

&lt;/div&gt;</pre>
</div>
<div class="laycode" style="width: 100%;float: left;height: auto;margin:0px;padding:0px;">
    <pre class="code">
 //设置laytpl的语法
laytpl.config({
    open : "<%",
    close:"%>"
});
var data = {};
data.area = [{"code":1,"name":"天河"},
            {"code":2,"name":"白云"},
            {"code":3,"name":"增城"}];
var tpl = laytpl($("#template").text());
var html = tpl.render(data);
$("#target").html(html);</pre>
</div>
<textarea style="display: none;" id="template">
    <select name="" id="">
        <%# for(var i=0;i<d.area.length;i++){ %>
        <option value="<%=d.area[i].code%>"><%=d.area[i].name%></option>
        <%# } %>
    </select>
</textarea>
<div id="target">

</div>
<script>
    (function(){
        $('.code').laycode({
            title: '我的代码',
            width:'100%',
            height: 'auto'
        });
        //设置laytpl的语法
        laytpl.config({
            open : "<%",
            close:"%>"
        });
        var data = {};
        data.area = [{"code":1,"name":"天河"},
                    {"code":2,"name":"白云"},
                    {"code":3,"name":"增城"}];
        var tpl = laytpl($("#template").text());
        var html = tpl.render(data);
        $("#target").html(html);
    })();
</script>